package com.qf.controller;

import com.qf.cache.AcountRecordCache;
import com.qf.dto.R;
import com.qf.entity.TAcountRecord;
import com.qf.service.AcountRecordService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/*
杨威
2021/10/30
15:44
*/
@RestController
@RequestMapping("/acount")
@Api("")
public class AcountRecordController {
    @Autowired
    AcountRecordCache acountRecordCache;
    @Autowired
    AcountRecordService acountRecordService;
    @GetMapping("/findAll")
    public R findAll(){
        List<TAcountRecord> allData = acountRecordCache.getAllData();
        return R.setOk(allData);
    }
    @GetMapping("/findById")
    public R findById(Long id){
        TAcountRecord acountRecord = acountRecordCache.getById(id);
        return R.setOk(acountRecord);
    }
    @PostMapping("/add")
    public R add(@RequestBody TAcountRecord tAcountRecord){
        acountRecordService.addAcountRescord(tAcountRecord);
        return R.setOk();
    }
    @DeleteMapping("/delete")
    public R delete(Long id){
        System.out.println("id = " + id);
        acountRecordService.deleteAcountRescord(id);
        return R.setOk();
    }
}
